package com.spring.spring.common;

import com.baomidou.mybatisplus.extension.api.R;
import lombok.Data;

@Data
public class Result {
    private int code;  //200成功，500失败
    private String msg;//成功   失败
    private long total;//总记录
    private Object data; //数据


    public static Result fail(){
        return result(500,"失败",0L,null);
    }

    public static Result suc(Object data){
        return result(200,"成功",0L,data);
    }
    public static Result suc(Object data,long total){
        return result(200,"成功",total,null);
    }
    private static Result result(int code,String msg,long total,Object data){
        Result res = new Result();
        res.setData(data);
        res.setMsg(msg);
        res.setCode(code);
        res.setTotal(total);
        return res;
    }
}
